package com.xiaoyushu.user.biz.rpc;

import com.xiaoyushu.distributed.id.generator.api.DistributedIdGeneratorFeignApi;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Component;

@Component
public class DistributedIdGeneratorRpcService {

    @Resource
    private DistributedIdGeneratorFeignApi distributedIdGeneratorFeignApi;
    /**
     * LEAF 号段模式:小鱼书 ID业务标识
     */
    private static final String BIZ_TAG_XIAOYUSHU_ID = "leaf-segment-xiaoyushu-id";

    private static final String BIZ_TAG_XIAOYUSHU_USER_ID = "leaf-snowflake-user-id";

    /**
     * 调用分布式 ID 生成服务生成小鱼书ID
     */
    public String getXioayushuId(){
        return distributedIdGeneratorFeignApi.getSegmentId(BIZ_TAG_XIAOYUSHU_ID);
    }

    public String getUserId(){
        return distributedIdGeneratorFeignApi.getSnowflakeId(BIZ_TAG_XIAOYUSHU_USER_ID);
    }
}